package com.spowin.Mansion88;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;

public class MansionDS {
	static final String LOGON_SITE = "www1.mansion88.com";

	static final int LOGON_PORT = 80;
	
	public static void main(String args[]) throws HttpException, IOException {
		HttpClient hc = new HttpClient();
		hc.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "http");

		hc.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

		HttpMethod get = new GetMethod();

		hc.executeMethod(get);
		// System.out.println(get.getResponseBodyAsString());
		get.releaseConnection();
/*
		HttpMethod get1 = new GetMethod("/left_menu_home.asp?PageTab=");

		hc.executeMethod(get1);
		// System.out.println(get1.getResponseBodyAsString());
		get1.releaseConnection();

		HttpMethod get2 = new GetMethod(
				"/OddsDisplay/MemberOdds/hdp.asp?sport=0&ViewType=ah&hdpver=2&OddsType=HK&PageNo=1&market=");

		hc.executeMethod(get2);

		// System.out.println(get2.getResponseBodyAsString());
		get2.releaseConnection();
		*/
		HttpMethod get3 = new GetMethod(
				"/OddsDisplay/MemberOdds/hdpdata.asp?sport=0&hdpver=2&ViewType=ah&PageNo=1&Uid=0.5751101252055805&timer=26487609&TypeNo=1&LeagueCode=");
		
		hc.executeMethod(get3);
		
		//System.out.println(get3.getResponseBodyAsString());
		
		
		
		System.out.println(get3.getResponseBodyAsString());
		InputStream is=get3.getResponseBodyAsStream();
		
		InputStreamReader isr=new InputStreamReader(is);
		
		BufferedReader br=new BufferedReader(isr);
		String nn=new String();

		List value=new ArrayList();

		while(nn!=null)
		{
			nn=br.readLine();
			value.add(nn);
			
		}
		List result=new ArrayList();
		
		for(int i=5;i<value.size()-7;i++)
		{
			MansionDSpojo po=Util.getMainsionDSpojo(value.get(i).toString());
			
			result.add(po);
		}
		get3.releaseConnection();
		MansionDSpojo pojo=(MansionDSpojo) result.get(0);
		System.out.println(pojo.getUnknownAttribute1());
		System.out.println(pojo.getLeageNameShort());
		System.out.println(pojo.getLeageNameFull());
		System.out.println(pojo.getUnknownAttribute2());
		System.out.println(pojo.getUnknownAttribute3());
		System.out.println(pojo.getGameDate());
		System.out.println(pojo.getGameTime());
		System.out.println(pojo.getRangQiuFlag());
		System.out.println(pojo.getHomeTeamName());
		System.out.println(pojo.getCustTeamName());
		System.out.println(pojo.getInRangQiuPanKouFullTime());
		System.out.println(pojo.getHkRangQiuPanKouFullTime());
		System.out.println(pojo.getShangPanFullTime());
		System.out.println(pojo.getXiaPanFullTime());
		System.out.println(pojo.getInDaXiaoPanKouFullTime());
		System.out.println(pojo.getHkDaXiaoPanKouFullTime());
		System.out.println(pojo.getDaQiuFullTime());
		System.out.println(pojo.getXiaoQiuFullTime());
		System.out.println(pojo.getHomeTeamWinFullTime());
		System.out.println(pojo.getHomeTeamLoseFullTime());
		System.out.println(pojo.getHomeTeamDrawFullTime());
		System.out.println(pojo.getDan());
		System.out.println(pojo.getShuang());
		System.out.println(pojo.getUnknownAttribute5());
		System.out.println(pojo.getUnknownAttribute6());
		System.out.println(pojo.getUnknownAttribute7());
		System.out.println(pojo.getUnknownAttribute8());
		System.out.println(pojo.getUnknownAttribute9());
		System.out.println(pojo.getUnknownAttribute10());
		System.out.println(pojo.getUnknownAttribute11());
		System.out.println(pojo.getUnknownAttribute12());
		System.out.println(pojo.getInRangQiuPanKouHalfTime());
		System.out.println(pojo.getHkRangQiuPanKouHalfTime());
		System.out.println(pojo.getShangPanHalfTime());
		System.out.println(pojo.getXiaPanHalfTime());
		System.out.println(pojo.getInDaXiaoPanKouHalfTime());
		System.out.println(pojo.getHkDaXiaoPanKouHalfTime());
		System.out.println(pojo.getDaQiuHalfTime());
		System.out.println(pojo.getXiaoQiuHalfTime());
		System.out.println(pojo.getHomeTeamWinHalfTime());
		System.out.println(pojo.getHomeTeamLoseHalfTime());
		System.out.println(pojo.getHomeTeamDrawHalfTime());
		
		
		
		
		
	
		

	}
}
